package com.financing.platform.service.impl;

import java.sql.SQLException;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.financing.platform.dao.IFaUserBlacklistDao;
import com.financing.platform.dao.IFaUserDao;
import com.financing.platform.dto.FaUserBlacklistDTO;
import com.financing.platform.dto.FaUserDTO;
import com.financing.platform.service.IFaUserBlacklistService;
import com.financing.platform.util.Dict;
import com.financing.platform.vo.FaUserBlacklistVO;

@Service("faUserBlacklistServiceImpl")
@Transactional
public class FaUserBlacklistServiceImpl extends BaseServiceImpl implements
		IFaUserBlacklistService {

	@Autowired
	private IFaUserBlacklistDao faUserBlacklistDaoImpl;
	
	@Autowired
	private IFaUserDao faUserDaoImpl;
	 

	@Override
	public int addFaUserBlacklist(FaUserBlacklistDTO faUserBlacklistDTO)
			throws SQLException {
		
		FaUserDTO bean = new FaUserDTO();
		bean.setId(faUserBlacklistDTO.getUserId());
		bean.setUpdateBy(faUserBlacklistDTO.getUpdateBy());
		bean.setUpdateDate(faUserBlacklistDTO.getUpdateDate());
		
		//加入拉黑  修改用户状态 04
		if(Dict.BLACKLIST_STATUS_JOIN.equals(faUserBlacklistDTO.getBlackType())){
			bean.setStatus(Dict.FA_USER_STATUS_BLACK);
			faUserDaoImpl.updateFaUserStatus(bean);
		}else if (Dict.BLACKLIST_STATUS_REMOVE.equals(faUserBlacklistDTO.getBlackType())){
			bean.setStatus(Dict.FA_USER_STATUS_NORMAL);
			faUserDaoImpl.updateFaUserStatus(bean);
		}
		return faUserBlacklistDaoImpl.addFaUserBlacklist(faUserBlacklistDTO);
	}

	@Override
	public List<FaUserBlacklistVO> queryFaUserBlacklist(FaUserBlacklistVO faUserBlacklistVO)
			throws SQLException {
		return faUserBlacklistDaoImpl.queryFaUserBlacklist(faUserBlacklistVO);
	}

	@Override
	public int queryFaUserBlacklistCount(FaUserBlacklistVO faUserBlacklistVO)
			throws SQLException {
		return faUserBlacklistDaoImpl.queryFaUserBlacklistCount(faUserBlacklistVO);
	}

	@Override
	public List<FaUserBlacklistDTO> queryBlacklistByUserId(
			FaUserBlacklistVO faUserBlacklistVO) throws SQLException {
		return faUserBlacklistDaoImpl.queryBlacklistByUserId(faUserBlacklistVO);
	}
	
	
}
